<?php

/**
 * Subclass for representing a row from the 'countries' table.
 *
 * 
 *
 * @package lib.model
 */ 
class Countries extends BaseCountries
{
	/**
	 * 
	 * returns array $ar[value] => name
	 */
	public static function getCountires()
	{
		$arr = array();
		$c = new Criteria();
		$c->add(CountriesPeer::CONTINENT, '%EU%', Criteria::LIKE);
		$countries = CountriesPeer::doSelect($c);
		if ($countries)
		{
			foreach ($countries as $country)
			{
				/* @var $country Countries */
				$arr[$country->getIso3166Numeric()] = $country->getCountry();
			}
			$arr[643] = 'Russia';
		}
		
		return $arr;
	}
	/**
	 * 
	 * returns numeric from countries table by alpha2 field
	 * @param string $alpha2
	 * @return integer
	 */
	public static function getNumeric($alpha2)
	{
		$numeric = 0;
		$c = new Criteria();
		$c->add(CountriesPeer::ISO_3166_ALPHA2, $alpha2);
		$countrie = CountriesPeer::doSelectOne($c);
		if($countrie)
		{
			/* @var $countrie Countries */
			$numeric = $countrie->getIso3166Numeric();
		}
		return $numeric;
	}
	/**
	 * 
	 * returns arra or short counties names
	 */
	public static function getCountriesEu()
	{
		$arr = array();
		$c = new Criteria();
		$c->add(CountriesPeer::CONTINENT, '%EU%', Criteria::LIKE);
		$countries = CountriesPeer::doSelect($c);
		if ($countries)
		{
			foreach ($countries as $key => $country)
			{
				/* @var $country Countries */
				$arr[$country->getIso3166Alpha2()] = '';
			}
			$arr['RU'] = '';
		}
		
		return $arr;
	}
}
